﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data.GraphClient;
using Semantics;
namespace SimpleGraphClient
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Please ensure the GraphServer is running on localhost!\r\n");
            Console.ReadKey();
            GraphConnection conneciton = new GraphConnection("localhost", "Demo");
            try
            {
                conneciton.Open();

                //Clear previsouly existing nodes and edges
                Node existingfrance = conneciton.ResolveNode("France");
                Node existingat = conneciton.ResolveNode("at");
                Node existingeurope = conneciton.ResolveNode("Europe");
                if (existingfrance != null && existingat != null && existingeurope != null)
                {
                    Edge existingedge = conneciton.GetEdge(existingfrance, existingat, existingeurope);
                    if(existingedge!=null)
                        conneciton.RemoveEdge(existingedge);
                }
                if (existingfrance != null)
                    conneciton.RemoveNode(existingfrance);
                if (existingat != null)
                    conneciton.RemoveNode(existingat);
                if (existingeurope != null)
                    conneciton.RemoveNode(existingeurope);

                //create nodes
                Node at = conneciton.AddNode("at");
                Node europe = conneciton.AddNode("Europe");
                Node france = conneciton.AddNode("France");
                

                //connect edges
                conneciton.ConnectNodes(france, at, europe);
                Node continent = conneciton.GetNodeProperty(france, at);
                ISuperGraph super = (ISuperGraph)conneciton;
                IGraph sub = super.CreateSubGraph("Transition1");
                conneciton.Close();
            }
            catch (Exception exp)
            {
                Console.Write(exp);
            }
            System.Console.ReadKey();
        }
    }
}
